home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / utils / cosaque / cosaque5.s < prev    next >
Text File  |  1980-01-03  |  44KB  |  1,984 lines

  1. *******************************************************************************
  2. * Cosaque v3.0 (GUI)                       Copyright © 1994 The Art/LSd
  3. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  4. * $Release    : 3.0 $
  5. * $Revision    : 1.00 $
  6. * $Date        : 14-Apr-94 $
  7. *
  8. * $Author(s)    : Written by The Art/LSd (In MC680x0 Assembly under Asm-One)
  9. * $Note(s)    : Position Independacy off a4 - (WARNING: DON`T TRASH A4!)
  10. *        : SysBase Ptr is cached so that if running in fastmem access
  11. *        : to SysBase ptr is faster. Requires Case Sensitivity enabled.
  12. *
  13. * $Purpose    : Nice and Simple sine generation tool with easy to use GUI
  14. *******************************************************************************
  15. SUCCESS        =    0            /* result return codes... */
  16. VAR_ERROR    =    1            /* memory alloction failcode */
  17. CONTEXT_ERROR    =    2            /* create context failcode */
  18. GADGETS_ERROR    =    3            /* create gadgets failcode */
  19. MENUS_ERROR    =    4            /* create menus failcode */
  20. WINDOW_ERROR    =    5            /* open window failcode */
  21. FONT_ERROR    =    6            /* open font failcode */
  22. SCREEN_ERROR    =    7            /* open screen failecode */
  23. VISUAL_ERROR    =    8            /* get visual info failcode */
  24.  
  25. AbsExecBase    =    $4
  26. _LVOSPMul    =    -$4E
  27. _LVOSPFix    =    -$1E
  28. _LVOSPFlt    =    -$24
  29. _LVOSPDiv    =    -$54
  30. _LVOSPAdd    =    -$42
  31. _LVOSPSub    =    -$48
  32. ;_LVOAllocMem    =    -$C6
  33. ;_LVOFreeMem    =    -$D2
  34.  
  35. AbsSysBase    =    4            /* Amiga AbsExecbase */
  36.  
  37. *-------------- Definition Includes...
  38.  
  39.         incdir    _include:
  40.         include    exec/exec.i
  41.         include    intuition/intuition.i
  42.         include    graphics/videocontrol.i
  43.         include    libraries/asl.i
  44.         include    libraries/gadtools.i
  45.         include    libraries/dos_lib.i
  46.         include    libraries/intuition_lib.i
  47.         include    libraries/graphics_lib.i
  48.         include    libraries/exec_lib.i
  49.         include    libraries/asl_lib.i
  50.         include    libraries/icon_lib.i
  51.         include    libraries/diskfont_lib.i
  52.         include    libraries/gadtools_lib.i
  53.         include    libraries/wb_lib.i
  54.         include    libraries/rexxsyslib_lib.i
  55.         include    libraries/utility_lib.i
  56.         include    libraries/dosextens.i
  57.         include    dos/datetime.i
  58.  
  59. *-------------- Definition of Main Variables (Public) Block...
  60.  
  61.         STRUCTURE VarsBlock,0
  62.  
  63.         APTR    _SysBase        /* ExecBase base */
  64.         APTR    _DosBase        /* DOS lib base */
  65.         APTR    _IntuitionBase        /* Intuition lib base */
  66.         APTR    _GfxBase        /* Graphics lib base */
  67.         APTR    _GadToolsBase        /* GadTools lib base */
  68.         APTR    _IconBase        /* Icon lib base */
  69.         APTR    _WBBase            /* Workbench lib base */
  70.  
  71.         APTR    _ScreenPt
  72.         APTR    _VisualInfo
  73.         APTR    _WindowPt
  74.         APTR    _GUI_GList
  75. ;        APTR    _GUI_Menus
  76.         APTR    _UserPort
  77.         APTR    _AppIcon        /* Application icon (OS2.x+) */
  78.         APTR    _AppMsgPort        /* message ReplyPort (App) */
  79.         APTR    _DiskObj
  80.  
  81.         APTR    _AslBase        ;Asl lib base
  82.         APTR    Asl_Request        ;Requester struct
  83.         STRUCT    PathBuffer,200        ;filepath string buffer
  84.  
  85.         LABEL    vars_SIZEOF
  86.  
  87. *-------------- Definition of Macros...
  88.  
  89. PUSH        macro
  90.         movem.l    \1,-(sp)
  91.         endm
  92. PULL        macro
  93.         movem.l    (sp)+,\1
  94.         endm
  95. PUSHW        macro
  96.         movem.w    \1,-(sp)
  97.         endm
  98. PULLW        macro
  99.         movem.w    (sp)+,\1
  100.         endm
  101. PUSHR        macro
  102.         move.l    \1,-(sp)
  103.         endm
  104. PULLR        macro
  105.         move.l    (sp)+,\1
  106.         endm
  107. CALL        macro
  108.         jsr    _LVO\1(a6)
  109.         endm
  110. CALLJ        macro
  111.         jmp    _LVO\1(a6)
  112.         endm
  113. CALLREL        macro
  114.         move.l    \2(a4),a6
  115.         CALL    \1
  116.         endm
  117. *******************************************************************************
  118. *-------------- Allocate our variables block
  119.  
  120. Startup:    move.l    d0,d7            ;save CLI params len
  121.         move.l    a0,a5            ;save CLI params ptr
  122.         suba.l    a1,a1            ;clear a1
  123.         move.l    4.w,a6            ;get execbase
  124.         CALL    FindTask        ;find *THIS* task
  125.         move.l    d0,a4            ;get task ptr
  126.         move.l    d7,d0            ;restore CLI params len
  127.         move.l    a5,a0            ;restore CLI params ptr
  128.         tst.l    pr_CLI(a4)        ;did we originate from CLI?
  129.         bne.s    ProgStart        ;yes... call our program
  130.         lea    pr_MsgPort(a4),a0    ;from wb.. handle wb_startup
  131.         move.l    a0,a4
  132.         CALL    WaitPort        ;wait for a message
  133.         move.l    a4,a0
  134.         CALL    GetMsg            ;then get it
  135.         move.l    d0,-(sp)
  136.         bsr.s    ProgStart
  137.         move.l    d0,d7            ;save CLI Return code
  138.         move.l    4.w,a6
  139.         CALL    Forbid
  140.         move.l    (sp)+,a1
  141.         CALL    ReplyMsg
  142.         move.l    d7,d0            ;exit code
  143.         rts
  144.  
  145. ProgStart:    move.l    #vars_SIZEOF,d0        ;length for our variables
  146.         move.l    #MEMF_PUBLIC+MEMF_CLEAR,d1 ;we want public mem, cleared
  147.         move.l    (AbsSysBase).w,a6    ;get SysBase
  148.         CALL    AllocMem        ;allocate it...
  149.         move.l    d0,a4            ;ptr to our RS.Variables base
  150.         bne.s    RSValid            ;did the alloc fail, if so exit
  151.         moveq    #VAR_ERROR,d0        ;Memory allocation fail code
  152.         rts
  153.  
  154. RSPtr:        dc.l    0
  155.  
  156. *-------------- From here a4 points to our variables area (DON`T DESTROY A4!)
  157.  
  158. RSValid:    move.l    a6,_SysBase(a4)        ;cache execptr in publicmem
  159.         lea    RSPtr(pc),a0
  160.         move.l    a4,(a0)    
  161.  
  162. *-------------- Open all libs we want to use
  163.  
  164.         lea    LibTags(pc),a0        ;pt to library script
  165.         bsr.w    OpenTagLibs        ;open libraries
  166.         beq.w    ShutDown        ;if failed to open.. exit
  167.  
  168. *-------------- Allocate ASL Requester
  169.  
  170.         move.l    _AslBase(a4),a6        ;get asl base in a6
  171.         moveq    #ASL_FileRequest,d0    ;requester type
  172.         lea    MainTags(pc),a0        ;taglist
  173.         CALL    AllocAslRequest        ;allocate asl request struct
  174.         move.l    d0,Asl_Request(a4)    ;save request struct
  175.         beq.w    ShutDown
  176.  
  177. *-------------- Open Main Screen & Window
  178.  
  179. Restart:    bsr.w    SetupScreen        ;open our screen
  180.         bne.w    ShutDown        ;exit if error occurs...
  181.  
  182. *-------------- set sine generation defaults
  183.  
  184.         move.w    #COS_YES,SineType        ;COS OR JUMP
  185.         move.l    #NORMAL,DirType            ;NORMAL OR UPSIDEDOWN
  186.         move.l    #0,CosMin            ;COS.MIN
  187.         move.l    #100,CosMax            ;COS.MAX
  188.         move.l    #100,NrData            ;NR. OF DATA
  189.         move.w    #SOURCE,SaveType        ;SOURCE or DATA
  190.         move.w    #"b",_DataType            ;DATA TYPE (b,w,l)
  191.         move.w    #_BYTE,SizeType            ;* DON`T FORGET THIS! *
  192.  
  193.         bsr.w    OpenWindow        ;open our window
  194.         bne.w    ShutDown        ;exit if error occurs...
  195.  
  196.         move.l    _GUI_GList(a4),a0
  197.         move.l    _WindowPt(a4),a1
  198.         suba.l    a2,a2
  199.         moveq    #12,d0
  200.         CALLREL    RefreshGList,_IntuitionBase
  201.  
  202. *-------------- Check for Intuition events and take appropriate actions
  203.         
  204. OSWaitLoop:    move.l    _UserPort(a4),a0    ;a0-->user port
  205.         CALLREL    WaitPort,_SysBase    ;wait for something to happen
  206.  
  207.         move.l    _UserPort(a4),a0    ;a0-->window pointer
  208.         CALLREL    GT_GetIMsg,_GadToolsBase
  209.         tst.l    d0            ;was there a message ?
  210.         beq.s    OSWaitLoop        ;if not loop back
  211.  
  212.         move.l    d0,a1            ;a1-->message
  213.         move.l    im_Class(a1),d2        ;d2=IDCMP flags
  214.         move.w    im_Code(a1),d3        ;code ( for VANILLAKEY )
  215.         move.l    im_IAddress(a1),a2    ;save gadget address
  216.         move.w    $26(a0),d0        ;gadgetid
  217.  
  218.         PUSHR    d0
  219.         CALL    GT_ReplyIMsg        ;reply to message
  220.         PULLR    d0
  221.  
  222.         cmp.l    #CLOSEWINDOW,d2
  223.         beq.w    ShutDown
  224.         cmp.l    #GADGETUP,d2        ;class_gadgetup
  225.         beq.s    GadgetEvent
  226.         ;cmp.l    #MENUPICK,d2        ;did user select menu?
  227.         ;beq.w    MenuEvent
  228.         bra.b    OSWaitLoop
  229.  
  230. GadgetEvent    tst.l    gg_UserData(a2)        ;is there a gad jump adr?
  231.         beq.s    OSWaitLoop        ;was a gadget assigned?
  232.         move.l    gg_UserData(a2),a0    ;get gad jump address
  233.         jmp    (a0)            ;jump to gadget routine
  234.  
  235. *-------------- Get Menus event numbers
  236.  
  237. MenuEvent    move.w    d3,d0            ;\
  238.         move.w    d3,d1            ;make copies
  239.         move.w    d3,d2            ;/
  240.         and.w    #%1111100000000000,d2    ;mask out only submenu
  241.         rol.w    #5,d2            ;d2.w=SUBITEM NUMBER
  242.         and.w    #%0000011111100000,d1    ;mask out only item
  243.         lsr.w    #5,d1            ;d1.w=ITEM NUMBER
  244.         and.w    #%0000000000011111,d0    ;d0.w=MENU NUMBER
  245.  
  246.         bsr.s    _Project        ;project menu
  247.         bra.w    OSWaitLoop
  248.  
  249. _Project    tst.w    d0
  250.         beq.s    menu1
  251.         cmp.w    #1,d0
  252.         beq.s    menu2
  253.         cmp.w    #2,d0
  254.         beq.s    menu3
  255.         bra.w    OSWaitLoop
  256. ;----------------------------------------------Menus
  257.         
  258. menu1        tst.w    d1
  259.         beq.s    OpenPrefs
  260.         cmp.w    #1,d1
  261.         beq.s    SaveAs
  262.         cmp.w    #3,d1
  263.         beq.s    About    
  264.         cmp.w    #5,d1            ;quit program selected on menu?
  265.         beq.w    ShutDown
  266.         bra.w    OSWaitLoop
  267.  
  268. menu2        tst.w    d1
  269.         beq.s    ResetDefaults
  270.         cmp.w    #1,d1
  271.         beq.s    LastSaved
  272.         cmp.w    #2,d1
  273.         beq.s    Restore
  274.         bra.w    OSWaitLoop
  275.  
  276. menu3        tst.w    d1
  277.         beq.s    CrIcons
  278.         bra.w    OSWaitLoop
  279.         
  280. ;-------------------------------------------Menu 1 Functions        
  281.  
  282. OpenPrefs    bra.w    OSWaitLoop
  283. SaveAs        bra.w    OSWaitLoop
  284.  
  285. ;-------------------------------------------Menu 2 Functions        
  286.  
  287. ResetDefaults    bra.w    OSWaitLoop
  288. LastSaved    bra.w    OSWaitLoop
  289. Restore        bra.w    OSWaitLoop
  290.  
  291. ;-------------------------------------------Menu 3 Functions        
  292. CrIcons        bra.w    OSWaitLoop
  293.  
  294.  
  295. ***********************************************************
  296.  
  297.  
  298. About        lea    btxt(pc),a1
  299.         lea    bmsg(pc),a2
  300.         move.l    a2,b1-btxt(a1)
  301.         lea    ltxt(pc),a2
  302.         lea    lmsg(pc),a5
  303.         move.l    a5,b2-btxt(a1)
  304.         lea    rtxt(pc),a3
  305.         lea    rmsg(pc),a5
  306.         move.l    a5,b3-btxt(a1)
  307.         moveq    #0,d0
  308.         moveq    #0,d1
  309.         move.w    #180,d2
  310.         move.w    #80,d3
  311.         suba.l    a0,a0
  312.         move.l    d5,a6
  313.         move.l    _IntuitionBase(a4),a6
  314.         jsr    -348(a6)
  315.  
  316.         bra.w    OSWaitLoop
  317.  
  318. btxt:        dc.b    0,1,0,0
  319.         dc.w    10,10
  320.         dc.l    0
  321. b1        dc.l    0,0
  322. ltxt:        dc.b    0,1,0,0
  323.         dc.w    5,3
  324.         dc.l    0
  325. b2        dc.l    0,0
  326. rtxt:        dc.b    0,1,0,0
  327.         dc.w    5,3
  328.         dc.l    0
  329. b3        dc.l    0,0
  330. bmsg:        dc.b    'Copyright © 1994 The Art/EX4!',0
  331. lmsg:        dc.b    ' Okay ',0
  332. rmsg:        dc.b    ' Okay ',0
  333.         even
  334.  
  335. GetCosineorJump    move.w    d3,SineType    ;SineType (COS or JUMP) .w
  336.         bra.w    OSWaitLoop
  337.         
  338. NormorReverse    and.l    #$0000ffff,d3
  339.         move.l    d3,DirType    ;DirType (NORMAL or UPSIDEDOWN) .l
  340.         bra.w    OSWaitLoop
  341.  
  342. DatType        move.w    d3,SaveType    ;SaveType (SOURCE or DATA) .w
  343.         bra.w    OSWaitLoop
  344.  
  345. Word        tst.w    d3
  346.         bne.s    notbyte
  347.         move.w    #"b",_DataType
  348.         move.w  #_BYTE,SizeType
  349.         bra.w    OSWaitLoop
  350.  
  351. notbyte:    cmp.w    #1,d3
  352.         bne.s    notword        
  353.         move.w    #"w",_DataType
  354.         move.w  #_WORD,SizeType
  355.         bra.w    OSWaitLoop
  356.  
  357. notword:    move.w    #"l",_DataType
  358.         move.w  #_LONG,SizeType        
  359.         bra.w    OSWaitLoop
  360.  
  361.  
  362. MinSize        lea     GUI_Gadgets+3*4(pc),a0
  363.         move.l    (a0),a0
  364.         move.l    34(a0),a0
  365.         move.l    (a0),a0
  366.         lea    -11*4(a0),a0
  367.         move.l    (a0),CosMin
  368.         bra.w    OSWaitLoop
  369.  
  370. MaxSize
  371.         lea     GUI_Gadgets+4*4,a0
  372.         move.l    (a0),a0
  373.         move.l    34(a0),a0
  374.         move.l    (a0),a0
  375.         lea    -11*4(a0),a0
  376.         move.l    (a0),CosMax
  377.         bra.w    OSWaitLoop
  378.  
  379. Number        lea     GUI_Gadgets+5*4,a0
  380.         move.l    (a0),a0
  381.         move.l    34(a0),a0
  382.         move.l    (a0),a0
  383.         lea    -11*4(a0),a0
  384.         move.l    (a0),NrData
  385.         bra.w    OSWaitLoop
  386.  
  387.  
  388. CreateSine    move.l    CosMin,d0
  389.         move.l    CosMax,d1
  390.         beq.s    skip
  391.         cmp.l    d0,d1
  392.         ble.s    skip
  393.         tst.l    NrData
  394.         beq.s    skip
  395.  
  396.         move.l    a4,-(sp)
  397.  
  398.         move.l    CosMin,_temp1
  399.         move.l    CosMax,_temp2
  400.         move.l    NrData,_temp3
  401.  
  402.         bsr.w    Do_Sine
  403.  
  404.         move.l    _temp1,CosMin
  405.         move.l    _temp2,CosMax
  406.         move.l    _temp3,NrData
  407.  
  408.         move.l    (sp)+,a4
  409.  
  410. skip        bra.w    OSWaitLoop
  411.  
  412. _temp1:        dc.l    0
  413. _temp2:        dc.l    0
  414. _temp3:        dc.l    0
  415.  
  416. GetSaveReq
  417. *-------------- Example ASL Requester 'SAVE'
  418.  
  419.         move.l    RSPtr(pc),a4
  420.         lea    SaveTags(pc),a1        ;address of taglist
  421.         lea    SaveText(pc),a2        ;ptr to requester hail text
  422.         bsr.b    RequestASL
  423.  
  424. *-------------- put name into gadget
  425.  
  426.         lea    GUI_Gadgets+7*4(pc),a0
  427.         lea    PathBuffer(a4),a2
  428.         bsr    CopyStr2Gad
  429.  
  430.         move.l    _GUI_GList(a4),a0
  431.         move.l    _WindowPt(a4),a1
  432.         suba.l    a2,a2
  433.         moveq    #12,d0
  434.         CALLREL    RefreshGList,_IntuitionBase
  435.         
  436. TypeSaveName:    bra.w    OSWaitLoop
  437.  
  438.  
  439. *******************************************************************************
  440. * RequestASL <NON MODIFIABLE>
  441. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  442. * Prompts user to select a filename using the ASL Requester
  443. *
  444. * $Inputs    : a1.l=Requester Tag Structure (PTR)
  445. *        : a2.l=Requester Hail Text-String (PTR)
  446. * $Outputs    : a0.l=Pathname of selected file, or Points to ZERO if failed
  447. *        : d0.b=Flags 0,cancelled, -1,selected
  448. *
  449. * $SR-Flags    : Z-Flag Set if requester cancelled.
  450. *******************************************************************************
  451.  
  452. RequestASL:    move.l    a2,4(a1)        ;hail textptr into tag struct
  453.         move.l    Asl_Request(a4),a0    ;address of requester struc
  454.         move.l    _AslBase(a4),a6        ;get asl base
  455.         CALL    AslRequest        ;do request
  456.         tst.l    d0            ;test d0
  457.         beq.s    cancelled        ;branch if cancelled
  458.  
  459.         lea    PathBuffer(a4),a5
  460.         move.l    Asl_Request(a4),a0    ;address of requester struc
  461.         move.l    rf_Dir(a0),a1        ;get dir string
  462.         move.l    a5,a2            ;get output buffer
  463.         moveq    #56,d0            ;set max size
  464. copy        move.b    (a1)+,(a2)+        ;copy bytes
  465.         dbeq    d0,copy            ;until end of string or buffer
  466.     
  467.         move.l    a5,d1            ;get dir name (copy)
  468.         move.l    rf_File(a0),d2        ;get file name
  469.         move.l    #200,d3            ;size of buffer
  470.         move.l    _DosBase(a4),a6        ;get dos base
  471.         CALL    AddPart            ;create full pathname
  472.         tst.l    d0            ;test for overflow
  473.         beq.s    cancelled        ;branch on error
  474.     
  475.         moveq    #-1,d0            ;initialise count
  476.         move.l    a5,a0            ;address of buffer    
  477. checksize:    addq.w    #1,d0            ;decrement counter
  478.         tst.b    0(a0,d0.w)        ;test for zero terminator
  479.         bne.s    checksize        ;branch if not found
  480.     
  481.         cmpi.w    #37,d0            ;is count too large
  482.         ble.s    sizeok            ;branch if not
  483.         sub.w    #37,d0            ;subtract count from numchars
  484.         add.w    d0,a0            ;add to buff adr so eostr shown
  485. sizeok        st.b    d0            ;d0=$FF.b (Clear Z-Flag)
  486.         rts
  487.  
  488. cancelled    suba.l    a0,a0            ;no filename, clear ptr
  489.         sf.b    d0            ;d0=$00.b (Set Z-Flag)
  490.         rts
  491.  
  492. *******************************************************************************
  493.  
  494. MainTags:    dc.l    ASL_Height,200                ;height
  495.         dc.l    ASL_Width,340                ;width
  496.         dc.l    TAG_DONE                ;end of taglist
  497.  
  498. SaveTags:    dc.l    ASL_Hail,0                ;savetext ptr
  499.         dc.l    ASL_FuncFlags,FILF_SAVE+FILF_PATGAD
  500.         dc.l    TAG_DONE                ;end of taglist
  501.  
  502. SaveText:    dc.b    'Save File',0
  503.         even
  504.  
  505. *******************************************************************************
  506. * Shutdown() - Free all allocated resources & exit program
  507. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  508. * Frees all previously allocated resources, sanity checks are made so only
  509. * allocated memory/open libraries/and so on will be removed if open/alloc`d.
  510. *******************************************************************************
  511. *-------------- Dealloc Open Libraries
  512.  
  513. ShutDown:    move.l    RSPtr(pc),a4
  514.  
  515.         move.l    Asl_Request(a4),d0    ;get request struct
  516.         beq.s    no_asl    
  517.         move.l    d0,a0
  518.         move.l    _AslBase(a4),a6
  519.         move.l    a6,d7
  520.         beq.s    no_asl
  521.         CALL    FreeAslRequest
  522. no_asl
  523.         bsr.w    CloseWindow
  524.         bsr.w    CloseDownScreen
  525.  
  526.         lea    LibTags(pc),a0        ;pt to taglist of libs to close
  527.         bsr.w    CloseTagLibs        ;close all open libs..
  528.  
  529. *-------------- Free RS Variables Area
  530.  
  531. RSFreeMem:    move.l    a4,a1            ;ptr to our RS.Variables base
  532.         move.l    #vars_SIZEOF,d0        ;no. of bytes to free
  533.         move.l    4.w,a6
  534.         CALL    FreeMem            ;free the memory
  535.  
  536.         moveq    #0,d0            ;no return code
  537.         rts                ;exit...
  538.  
  539. *******************************************************************************
  540. * IconifyAsApp()
  541. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  542. * Free`s up as much memory as possible then shuts down window`s & screens. Next
  543. * it Opens up an Application Icon on WB screen and waits for user to select it
  544. * before Restarting Program.
  545. *******************************************************************************
  546.  
  547. IconifyAsApp:    bsr.w    CloseWindow
  548.         bsr.w    CloseDownScreen
  549.         bsr.s    AppIconify
  550.         bra    Restart
  551.  
  552. ;/* [ CloseDownApp ] *********************************************************/
  553. ;Add an Application Icon to WB screen and waits until icon selected then exits.
  554.  
  555. *-------------- Create App Msgport (for reply)
  556.  
  557. AppIconify:    clr.l    _AppMsgPort(a4)
  558.         move.l    _WBBase(a4),d0
  559.         CALLREL    CreateMsgPort,_SysBase        ; make app msgport
  560.         move.l    d0,_AppMsgPort(a4)
  561.         beq.s    FreeApp
  562.  
  563. *-------------- Get DiskObject (For WB AppIcon access)
  564.  
  565.         lea    IconName(pc),a0
  566.         CALLREL    GetDiskObject,_IconBase        ;get icon
  567.         move.l    d0,_DiskObj(a4)
  568.         beq.s    FreeApp
  569.         
  570. *-------------- Create the WB Application Icon
  571.  
  572.         lea    SproName(pc),a0        ; Icon name
  573.         move.l    _AppMsgPort(a4),a1    ; reply port is MSGPort
  574.         suba.l    a2,a2            ; lock (not used as v39)
  575.         move.l    _DiskObj(a4),a3        ; disk object (icon image)
  576.         move.l    a3,d0            ; a3=icon image
  577.         beq.s    NoDiskOb
  578.         moveq    #0,d0            ; id
  579.         moveq    #0,d1            ; userdata
  580.         move.l    _WBBase(a4),a6        ; is there a WB Libray open?
  581.         move.l    a4,-(sp)        ; stack our RS. Area pt
  582.         move.l    d0,a4            ; clear a4 - for OS2 TagCompat!
  583.         CALL    AddAppIconA        ; Call call
  584.         move.l    (sp)+,a4        ; get our RS. area ptr back!
  585.         move.l    d0,_AppIcon(a4)        ; ptr to appicon
  586.  
  587. *-------------- Wait for user to select icon on WB Screen
  588.  
  589. NoDiskOb:    move.l    _SysBase(a4),a6        ; get execbase
  590.         moveq    #0,d6
  591. WaitOnApp:    move.l    _AppMsgPort(a4),a0
  592.         moveq    #0,d0
  593.         moveq    #1,d1
  594.         move.b    15(a0),d1
  595.         bset    d1,d0
  596.         CALL    Wait            ; wait for msg
  597.  
  598.         move.l    _AppMsgPort(a4),a0
  599.         CALL    GetMsg            ; get it...
  600.         tst.l    d0            ; was there a message ?
  601.         beq.s    WaitOnApp        ;if not loop back
  602.  
  603.         move.l    d0,a0
  604.         tst.l    32(a0)            ; appicon selected?
  605.         sne    d6            ; set d6 if so..
  606.         move.l    a0,a1
  607.         CALL    ReplyMsg        ; reply to msg...
  608.         tst.b    d6
  609.         bne.s    WaitOnApp
  610.  
  611. *-------------- Remove Application Icon from Workbench screen (& Kill MsgPort)
  612.  
  613. FreeApp:    move.l    _AppMsgPort(a4),d0
  614.         beq.s    NoPort
  615.         move.l    d0,a0
  616.         CALLREL    DeleteMsgPort,_SysBase    ;delete msgport
  617.         clr.l    _AppMsgPort(a4)
  618.  
  619. *-------------- Free WB Application Icon
  620.  
  621. NoPort:        move.l    _AppIcon(a4),d0        ; Our app icon
  622.         beq.s    No_App
  623.         move.l    d0,a0
  624.         CALLREL    RemoveAppIcon,_WBBase    ; get rid of app icon
  625.         clr.l    _AppIcon(a4)
  626.  
  627. *-------------- Free DiskObject (Used For WB AppIcon access)
  628.  
  629.         move.l    _DiskObj(a4),d0        ; d0=disk object
  630.         beq.s    No_App            ; is it valid, if not skip free
  631.         move.l    d0,a0
  632.         CALLREL    FreeDiskObject,_IconBase ; free up disk object
  633.         clr.l    _DiskObj(a4)
  634. No_App:        rts
  635.  
  636.  
  637.  
  638. *******************************************************************************
  639. * SaveMem2File
  640. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  641. * $Inputs:    a0.l    = Filename
  642. *        a1.l    = Mem Address
  643. *        d0.l    = Save Length
  644. *
  645. * $Outputs:    d0.l    = 0 - success
  646. *        d0.l    = 1 - failure
  647. *******************************************************************************
  648.  
  649. SaveMem2File:    movem.l    d2-d7/a0-a6,-(sp)
  650.  
  651.         move.l    a0,d1            ;filename
  652.         move.l    a1,d5            ;progbuffer
  653.         move.l    d0,d6            ;proglength
  654.         move.l    #MODE_NEWFILE,d2
  655.         move.l    _DosBase(a4),a6
  656.         jsr    _LVOOpen(a6)
  657.  
  658.         move.l    d0,d7
  659.         beq.b    _SaveError
  660.         move.l    d7,d1            ;fh...
  661.         move.l    d5,d2            ;adr
  662.         move.l    d6,d3            ;length
  663.         jsr    _LVOWrite(a6)        ;write file
  664.  
  665.         move.l    d7,d1
  666.         jsr    _LVOClose(a6)        ;close file
  667.  
  668.         movem.l    (sp)+,d2-d7/a0-a6
  669.         moveq    #0,d0
  670.         rts
  671.  
  672. _SaveError:    movem.l    (sp)+,d2-d7/a0-a6
  673. remcode        moveq    #1,d0
  674.         rts
  675.             
  676. ******************************************************************************
  677. * OpenTagLibs() <NON MODIFIABLE> 
  678. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  679. * $Inputs    : a0.l    = Taglist Pt
  680. * $Format eg;    : dc    DOSName-*,_DOSBase,36
  681. *
  682. * $Outpus    : d0.b  = $FF.B if FAILED & $00.B if OKAY
  683. * $SR-Flags    : Z-Flag cleared on FAIL
  684. ******************************************************************************
  685.         
  686. OpenTagLibs:    PUSH    d1-d7/a1-a3/a5-a6    ;save registers
  687.         move.l    _SysBase(a4),a6        ;execbase in a6
  688.         move.l    a0,a5
  689. .find_tag:    tst.w    (a5)            ;TAG_DONE?
  690.         beq.s    .tag_done        ;end of taglist?
  691.         move.l    a5,a1            ;start of script
  692.         add.w    (a5)+,a1        ;a1=library name pt
  693.         moveq    #0,d7            ;clear d7
  694.         move.l    d7,d0            ;clear d0 for version no.
  695.         move.w    (a5)+,d7        ;d7=_XXXBase pt
  696.         move.w    (a5)+,d0        ;d0=lib version.
  697.         PUSHR    a1            ;stack libname pt
  698.         CALL    OpenLibrary        ;try to open desired library
  699.         PULLR    a1            ;get libname pt
  700.         move.l    d0,(a4,d7.w)        ;save lib base (to RS.)
  701.         bne.s    .find_tag        ;did it open? if so open next..
  702.         sf.b    d0            ;set Z Flag (d0=$00.B) FAILED!
  703.         bra.s    .pullexit        ;clean up stack and return
  704. .tag_done:    st.b    d0            ;clear Z Flag (d0=$FF.B) OKAY!
  705. .pullexit:    PULL    d1-d7/a1-a3/a5-a6    ;restore registers
  706.         tst.b    d0
  707.         rts                ;libraries opened succefully!
  708.  
  709. CloseTagLibs:    PUSH    d0-d7/a0-a3/a5-a6    ;save registers
  710.         move.l    a0,a5            ;make copy of taglist ptr
  711.         move.l    4.w,a6            ;execbase in a6
  712. .find_tag:    tst.w    (a0)+            ;TAG_DONE?
  713.         beq.s    .tag_done        ;end of taglist?
  714.         move.l    a4,a1            ;get RS. base
  715.         add.w    (a0)+,a1        ;create LibBase pt
  716.         move.l    (a1),d0            ;is this library open?
  717.         beq.s    .find_tag        ;no.. so don`t close it..
  718.         move.l    d0,a1            ;base of library to close
  719.         tst.w    (a0)+            ;skip version
  720.         PUSHR    a0            ;stack script pt
  721.         CALL    CloseLibrary        ;close this library
  722.         PULLR    a0            ;get script pt
  723.         bra.s    .find_tag        ;next tagitem please!
  724. .tag_done:    PULL    d0-d7/a0-a3/a5-a6    ;restore registers
  725. script_done:    rts                ;all open libraries closed..
  726.  
  727. LibTags:    dc    DOSName-*,_DosBase,36
  728.         dc    INTName-*,_IntuitionBase,36
  729.         dc    GFXName-*,_GfxBase,36
  730.         dc    GTName-*,_GadToolsBase,36
  731.         dc    ICName-*,_IconBase,36
  732.         dc    WBName-*,_WBBase,0
  733.         dc    ASLName-*,_AslBase,36
  734.         dc    TAG_DONE
  735.  
  736. IR:        dc.l    GTBB_Recessed,1
  737. NR:        dc.l    GT_VisualInfo,0
  738.         dc.l    TAG_DONE
  739.  
  740. DOSName:    dc.b    "dos.library",0
  741. INTName:    dc.b    "intuition.library",0
  742. GFXName:    dc.b    "graphics.library",0
  743. GTName:        dc.b    "gadtools.library",0
  744. WBName:        dc.b    "workbench.library",0
  745. ICName:        dc.b    "icon.library",0
  746. ASLName:    dc.b    "asl.library",0    
  747.         even
  748.         cnop    0,4
  749.  
  750. SetupScreen:    move.l    PubScreenName(pc),a0
  751.         move.l    _IntuitionBase(a4),a6
  752.         jsr    _LVOLockPubScreen(a6)
  753.         move.l    d0,_ScreenPt(a4)
  754.         beq.s    SError
  755.  
  756.         move.l    _ScreenPt(a4),a0
  757.         lea    TD(pc),a1
  758.         move.l    _GadToolsBase(a4),a6
  759.         jsr    _LVOGetVisualInfoA(a6)
  760.         move.l    d0,_VisualInfo(a4)
  761.         beq.s    VError
  762.  
  763.         moveq    #0,d0
  764.         rts
  765.  
  766. SError:     moveq   #1,d0
  767.         rts
  768. VError:        moveq   #2,d0
  769.         rts
  770.  
  771.  
  772.  
  773. WindowRender:
  774.     movem.l d0-d5/a0-a2/a6,-(sp)
  775.  
  776.     move.l  _WindowPt(a4),a0
  777.     move.b  wd_BorderLeft(a0),d4
  778.     ext.w   d4
  779.     move.b  wd_BorderTop(a0),d5
  780.     ext.w   d5
  781.     move.l  _VisualInfo(a4),NR+4
  782.     move.l  _VisualInfo(a4),IR+4
  783.     move.l  _WindowPt(a4),a0
  784.     move.l  wd_RPort(a0),a2
  785.     move.l  a2,a0
  786.     lea.l   IR,a1
  787.     move.w  #4,d0
  788.     add.w   d4,d0
  789.     move.w  #110,d1
  790.     add.w   d5,d1
  791.     move.w  #60,d2
  792.     move.w  #14,d3
  793.     move.l  _GadToolsBase(a4),a6
  794.     jsr     _LVODrawBevelBoxA(a6)
  795.  
  796.     move.l  _WindowPt(a4),a0
  797.     move.l  wd_RPort(a0),a0
  798.     lea.l   GUI_Text0(pc),a1
  799.     move.l  d4,d0
  800.     move.l  d5,d1
  801.     move.l  _IntuitionBase(a4),a6
  802.     jsr     _LVOPrintIText(a6)
  803.  
  804.     movem.l (sp)+,d0-d5/a0-a2/a6
  805.     rts
  806.  
  807. OpenWindow:
  808.     movem.l d1-d4/a0-a5/a6,-(sp)
  809.  
  810.     move.l  _ScreenPt(a4),a0
  811.     moveq   #0,d3
  812.     moveq   #0,d2
  813.     move.b  sc_WBorLeft(a0),d2
  814.     move.l  sc_Font(a0),a1
  815.     move.w  ta_YSize(a1),d3
  816.     addq.w  #1,d3
  817.     move.b  sc_WBorTop(a0),d0
  818.     ext.w   d0
  819.     add.w   d0,d3
  820.     move.l  _GadToolsBase(a4),a6
  821.     lea   _GUI_GList(a4),a0
  822.     jsr     _LVOCreateContext(a6)
  823.     move.l  d0,a3
  824.     beq     GUI_CError
  825.  
  826.     movem.w d2-d3,-(sp)
  827.     moveq   #0,d3
  828.     lea.l   GUI_GTags(pc),a5
  829. GUI_GL:
  830.     move.l  _SysBase(a4),a6
  831.     lea.l   GUI_NGads,a0
  832.     move.l  d3,d0
  833.     mulu    #gng_SIZEOF,d0
  834.     add.l   d0,a0
  835.     lea.l   BufNewGad,a1
  836.     moveq   #gng_SIZEOF,d0
  837.     jsr     _LVOCopyMem(a6)
  838.  
  839.     lea.l   BufNewGad,a0
  840.     move.l  _VisualInfo(a4),gng_VisualInfo(a0)
  841.     move.l  #topaz8,gng_TextAttr(a0)
  842.     move.w  gng_LeftEdge(a0),d0
  843.     add.w   (sp),d0
  844.     move.w  d0,gng_LeftEdge(a0)
  845.     move.w  gng_TopEdge(a0),d0
  846.     add.w   2(sp),d0
  847.     move.w  d0,gng_TopEdge(a0)
  848.  
  849.     move.l  _GadToolsBase(a4),a6
  850.     lea.l   GUI_GTypes,a0
  851.     moveq   #0,d0
  852.     move.l  d3,d1
  853.     asl.l   #1,d1
  854.     add.l   d1,a0
  855.     move.w  (a0),d0
  856.     move.l  a3,a0
  857.     lea.l   BufNewGad,a1
  858.     move.l  a5,a2
  859.     jsr     _LVOCreateGadgetA(a6)
  860.     tst.l   d0
  861.     bne.s    GUI_COK
  862.     movem.w (sp)+,d2-d3
  863.     bra     GUI_GError
  864. GUI_COK:
  865.     move.l  d0,a3
  866.     move.l  d3,d0
  867.     asl.l   #2,d0
  868.     lea.l   GUI_Gadgets,a0
  869.     add.l   d0,a0
  870.     move.l  a3,(a0)
  871.     move.l  a3,a0
  872.     move.l  d3,d0
  873.     asl.l   #1,d0
  874.     lea.l   GUI_GTypes,a1
  875.     add.l   d0,a1
  876. GUI_NoGen1:
  877. GUI_TL:
  878.     tst.l   (a5)
  879.     beq.s   GUI_DN
  880.     addq.w  #8,a5
  881.     bra.s   GUI_TL
  882. GUI_DN:
  883.     addq.w  #4,a5
  884.     addq.w  #1,d3
  885.     cmp.w   #GUI__CNT,d3
  886.     bmi     GUI_GL
  887.     movem.w (sp)+,d2-d3
  888.     move.l  _GUI_GList(a4),GUI_WG+4
  889.  
  890. ;    move.l  _GadToolsBase(a4),a6
  891. ;    lea.l   GUI_NewMenu0,a0
  892. ;    lea.l   MTags0,a1
  893. ;    jsr     _LVOCreateMenusA(a6)
  894. ;    move.l  d0,_GUI_Menus(a4)
  895. ;    beq     GUI_MError
  896. ;
  897. ;    move.l  d0,a0
  898. ;    move.l  _VisualInfo(a4),a1
  899. ;    lea.l   MTags1,a2
  900. ;    jsr     _LVOLayoutMenusA(a6)
  901.  
  902.     move.w  GUI_Left,GUI_Zoom
  903.     move.w  GUI_Top,GUI_Zoom+2
  904.  
  905.     move.l  _GfxBase(a4),a6
  906.     move.l  _ScreenPt(a4),a1
  907.     lea.l   sc_RastPort(a1),a1
  908.     lea.l   GUI_WTitle,a0
  909.     move.l  #24,d0
  910.     jsr     _LVOTextLength(a6)
  911.     add.w   #80,d0
  912.     move.w  d0,GUI_Zoom+4
  913.  
  914.     move.l  _ScreenPt(a4),a0
  915.     move.b  sc_WBorTop(a0),d0
  916.     ext.w   d0
  917.     lea.l   sc_RastPort(a0),a0
  918.     add.w   rp_TxHeight(a0),d0
  919.     addq.w  #1,d0
  920.     move.w  d0,GUI_Zoom+6
  921.     moveq   #0,d0
  922.     move.w  GUI_Left,d0
  923.     move.l  d0,GUI_L+4
  924.     move.w  GUI_Top,d0
  925.     move.l  d0,GUI_T+4
  926.     move.w  GUI_Width,d0
  927.     move.l  d0,GUI_W+4
  928.     move.w  GUI_Height,d0
  929.     add.w   d3,d0
  930.     move.l  d0,GUI_H+4
  931.  
  932.     move.l  _IntuitionBase(a4),a6
  933.     suba.l  a0,a0
  934.     lea    GUI_WindowTags(pc),a1
  935.     jsr     _LVOOpenWindowTagList(a6)
  936.     move.l  d0,_WindowPt(a4)        ;did window open?
  937.     beq    GUI_WError
  938.  
  939.     move.l    d0,a0                ;window pt
  940.     move.l    wd_UserPort(a0),_UserPort(a4)    ;save user port
  941. ;    move.l   _GUI_Menus(a4),a1
  942. ;    jsr    _LVOSetMenuStrip(a6)
  943.  
  944. *-------------- set default save filename...
  945.  
  946.         lea    GUI_Gadgets+7*4(pc),a0
  947.         lea    fname,a2
  948.         bsr    CopyStr2Gad
  949.  
  950.         lea     GUI_Gadgets+4*4(pc),a0
  951.         move.l    (a0),a0
  952.         move.l    34(a0),a0
  953.         move.l    (a0),a0
  954.         move.b    #"1",(a0)
  955.         move.b    #"0",1(a0)
  956.         move.b    #"0",2(a0)
  957.  
  958.         lea     GUI_Gadgets+5*4(pc),a0
  959.         move.l    (a0),a0
  960.         move.l    34(a0),a0
  961.         move.l    (a0),a0
  962.         move.b    #"1",(a0)
  963.         move.b    #"0",1(a0)
  964.         move.b    #"0",2(a0)
  965.         
  966.  
  967.     move.l  _GadToolsBase(a4),a6
  968.     move.l  _WindowPt(a4),a0
  969.     suba.l  a1,a1
  970.     jsr     _LVOGT_RefreshWindow(a6)
  971.  
  972.     bsr     WindowRender
  973.  
  974.     moveq   #0,d0
  975. GUI_Done:
  976.     movem.l (sp)+,d1-d4/a0-a5/a6
  977.     rts
  978.  
  979. GUI_CError:
  980.     moveq   #1,d0
  981.     bra.s   GUI_Done
  982. GUI_GError:
  983.     moveq   #2,d0
  984.     bra.s   GUI_Done
  985. GUI_MError:
  986.     moveq   #3,d0
  987.     bra.s   GUI_Done
  988. GUI_WError:
  989.     moveq   #4,d0
  990.     bra.s   GUI_Done
  991.  
  992. *******************************************************************************
  993. * [CLOSE GUI]
  994. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  995. *******************************************************************************
  996.  
  997. CloseDownScreen    move.l    _VisualInfo(a4),d0
  998.         beq.s   NoVis
  999.         move.l    d0,a0
  1000.         CALLREL    FreeVisualInfo,_GadToolsBase
  1001.         clr.l    _VisualInfo(a4)
  1002.  
  1003. NoVis:        suba.l  a0,a0
  1004.         move.l  _ScreenPt(a4),a1
  1005.         cmpa.l  a0,a1
  1006.         beq.s   NoScr
  1007.         CALLREL    UnlockPubScreen,_IntuitionBase
  1008.         clr.l  _ScreenPt(a4)
  1009. NoScr:        rts
  1010.  
  1011. CloseWindow:    ;move.l    _GUI_Menus(a4),d0            ;any menus?
  1012. ;        beq.s    no_menus
  1013. ;        move.l    d0,d7
  1014. ;        move.l   _WindowPt(a4),a0
  1015. ;        CALLREL    ClearMenuStrip,_IntuitionBase
  1016. ;        move.l    d7,a0
  1017. ;        CALLREL    FreeMenus,_GadToolsBase
  1018. ;        clr.l    _GUI_Menus(a4)
  1019.  
  1020. no_menus:    move.l    _WindowPt(a4),d0
  1021.         beq.s    no_window
  1022.         move.l    d0,a0
  1023.         CALLREL    CloseWindow,_IntuitionBase
  1024.         clr.l    _WindowPt(a4)
  1025.  
  1026. no_window:    move.l    _GUI_GList(a4),d0
  1027.         beq.s    no_gadgets
  1028.         move.l    d0,a0
  1029.         CALLREL    FreeGadgets,_GadToolsBase
  1030.         clr.l    _GUI_GList(a4)
  1031. no_gadgets:    rts
  1032.  
  1033.  
  1034.  
  1035.  
  1036. GD_Gadget00                            EQU    0
  1037. GD_Gadget10                            EQU    1
  1038. GD_Gadget20                            EQU    2
  1039. GD_Gadget30                            EQU    3
  1040. GD_Gadget40                            EQU    4
  1041. GD_Gadget50                            EQU    5
  1042. GD_Gadget60                            EQU    6
  1043. GD_Gadget70                            EQU    7
  1044. GD_Gadget80                            EQU    8
  1045. GD_Gadget90                            EQU    9
  1046. GD_Gadget100                           EQU    10
  1047. GD_Gadget110                           EQU    11
  1048. GD_Gadget120                           EQU    12
  1049. GD_Gadget130                           EQU    13
  1050.  
  1051. GUI__CNT    EQU    14
  1052.  
  1053. PubScreenName:
  1054.     DC.L    WB_Name
  1055. WB_Name:
  1056.     DC.B    'Workbench',0
  1057.     CNOP  0,2
  1058.  
  1059. MTags0:        dc.l    GTMN_FrontPen,1
  1060.         dc.l    GTMN_NewLookMenus,1
  1061.         dc.l    TAG_DONE
  1062. MTags1:
  1063.    dc.l    TAG_DONE
  1064. GUI_Zoom:
  1065.     DC.W    0,0,0,0
  1066. GUI_Gadgets:
  1067.     DCB.L    14,0
  1068. BufNewGad:
  1069.     DC.W    0,0,0,0
  1070.     DC.L    0,0
  1071.     DC.W    0
  1072.     DC.L    0,0,0
  1073. TD:
  1074.     DC.L    TAG_DONE
  1075. CL:
  1076.     DC.L    GT_VisualInfo,0,TAG_DONE
  1077. GUI_Left:
  1078.     DC.W    98
  1079. GUI_Top:
  1080.     DC.W    31
  1081. GUI_Width:
  1082.     DC.W    310
  1083. GUI_Height:
  1084.     DC.W    144
  1085.  
  1086. GUI_GTypes:
  1087.     DC.W    CYCLE_KIND
  1088.     DC.W    CYCLE_KIND
  1089.     DC.W    CYCLE_KIND
  1090.     DC.W    INTEGER_KIND
  1091.     DC.W    INTEGER_KIND
  1092.     DC.W    INTEGER_KIND
  1093.     DC.W    BUTTON_KIND
  1094.     DC.W    STRING_KIND
  1095.     DC.W    BUTTON_KIND
  1096.     DC.W    BUTTON_KIND
  1097.     DC.W    CYCLE_KIND
  1098.     DC.W    TEXT_KIND
  1099.     DC.W    BUTTON_KIND
  1100.     DC.W    BUTTON_KIND
  1101.  
  1102.  
  1103. GUI_NGads:
  1104.     DC.W    4,15,110,15
  1105.     DC.L    Gadget00Text,0
  1106.     DC.W    GD_Gadget00
  1107.     DC.L    PLACETEXT_ABOVE,0,GetCosineorJump
  1108.  
  1109.     DC.W    4,76,111,15
  1110.     DC.L    Gadget10Text,0
  1111.     DC.W    GD_Gadget10
  1112.     DC.L    PLACETEXT_ABOVE,0,Word
  1113.  
  1114.     DC.W    4,45,111,15
  1115.     DC.L    Gadget20Text,0
  1116.     DC.W    GD_Gadget20
  1117.     DC.L    PLACETEXT_ABOVE,0,DatType
  1118.  
  1119.     DC.W    237,15,57,15
  1120.     DC.L    Gadget30Text,0
  1121.     DC.W    GD_Gadget30
  1122.     DC.L    PLACETEXT_ABOVE,0,MinSize
  1123.  
  1124.     DC.W    238,46,56,15
  1125.     DC.L    Gadget40Text,0
  1126.     DC.W    GD_Gadget40
  1127.     DC.L    PLACETEXT_ABOVE,0,MaxSize
  1128.  
  1129.     DC.W    241,76,55,15
  1130.     DC.L    Gadget50Text,0
  1131.     DC.W    GD_Gadget50
  1132.     DC.L    PLACETEXT_ABOVE,0,Number
  1133.  
  1134.     DC.W    68,110,20,14
  1135.     DC.L    Gadget60Text,0
  1136.     DC.W    GD_Gadget60
  1137.     DC.L    0,0,GetSaveReq
  1138.  
  1139.     DC.W    91,110,206,14
  1140.     DC.L    0,0                    ;Gadget70Text,0
  1141.     DC.W    GD_Gadget80
  1142.     DC.L    PLACETEXT_IN,0,TypeSaveName
  1143. ;    DC.L    0,0,0
  1144.  
  1145.     DC.W    2,127,105,14
  1146.     DC.L    Gadget80Text,0
  1147.     DC.W    GD_Gadget80
  1148.     DC.L    PLACETEXT_IN,0,About
  1149.  
  1150.     DC.W    197,127,101,14
  1151.     DC.L    Gadget90Text,0
  1152.     DC.W    GD_Gadget90
  1153.     DC.L    PLACETEXT_IN,0,ShutDown        ;was quit selected?
  1154.  
  1155.     DC.W    123,15,106,15
  1156.     DC.L    Gadget100Text,0
  1157.     DC.W    GD_Gadget100
  1158.     DC.L    PLACETEXT_ABOVE,0,NormorReverse
  1159.  
  1160.     DC.W    72,94,222,14
  1161.     DC.L    Gadget110Text,0
  1162.     DC.W    GD_Gadget110
  1163.     DC.L    PLACETEXT_LEFT,0,0
  1164.  
  1165.     DC.W    123,32,107,59
  1166.     DC.L    Gadget120Text,0
  1167.     DC.W    GD_Gadget120
  1168.     DC.L    PLACETEXT_IN,0,CreateSine
  1169.  
  1170.     DC.W    110,127,85,14
  1171.     DC.L    Gadget130Text,0
  1172.     DC.W    GD_Gadget130
  1173.     DC.L    PLACETEXT_IN,0,IconifyAsApp
  1174.  
  1175. GUI_GTags:
  1176.     DC.L    GTCY_Labels,Gadget00Labels
  1177.     DC.L    GT_Underscore,'_'
  1178.     DC.L    TAG_DONE
  1179.  
  1180.     DC.L    GTCY_Labels,Gadget10Labels
  1181.     DC.L    GT_Underscore,'_'
  1182.     DC.L    TAG_DONE
  1183.  
  1184.     DC.L    GTCY_Labels,Gadget20Labels
  1185.     DC.L    GT_Underscore,'_'
  1186.     DC.L    TAG_DONE
  1187.  
  1188.     DC.L    GTIN_Number,0
  1189.     DC.L    GTIN_MaxChars,10
  1190.     DC.L    STRINGA_Justification,GACT_STRINGCENTER
  1191.     DC.L    GT_Underscore,'_'
  1192.     DC.L    TAG_DONE
  1193.  
  1194.     DC.L    GTIN_Number,0
  1195.     DC.L    GTIN_MaxChars,10
  1196.     DC.L    STRINGA_Justification,GACT_STRINGCENTER
  1197.     DC.L    GT_Underscore,'_'
  1198.     DC.L    TAG_DONE
  1199.  
  1200.     DC.L    GTIN_Number,0
  1201.     DC.L    GTIN_MaxChars,10
  1202.     DC.L    STRINGA_Justification,GACT_STRINGCENTER
  1203.     DC.L    TAG_DONE
  1204.  
  1205.     DC.L    TAG_DONE
  1206.  
  1207.     DC.L    GTST_MaxChars,256
  1208.     DC.L    TAG_DONE
  1209.  
  1210.     DC.L    GT_Underscore,'_'
  1211.     DC.L    TAG_DONE
  1212.     DC.L    GT_Underscore,'_'
  1213.     DC.L    TAG_DONE
  1214.     DC.L    GTCY_Labels,Gadget100Labels
  1215.     DC.L    GT_Underscore,'_'
  1216.     DC.L    TAG_DONE
  1217.     DC.L    GTTX_Text,Gadget110String
  1218.     DC.L    GTTX_Border,1
  1219.     DC.L    TAG_DONE
  1220.     DC.L    TAG_DONE
  1221.     DC.L    GT_Underscore,'_'
  1222.     DC.L    TAG_DONE
  1223.  
  1224.  
  1225. Gadget110String:
  1226.     DC.B    '....OK!',0
  1227.     CNOP    0,2
  1228.  
  1229. Gadget00Text:
  1230.     DC.B    '_Sine Type',0
  1231.  
  1232. Gadget10Text:
  1233.     DC.B    'Size of Data',0
  1234.  
  1235. Gadget20Text:
  1236.     DC.B    '_Data Type',0
  1237.  
  1238. Gadget30Text:
  1239.     DC.B    '_Min.',0
  1240.  
  1241. Gadget40Text:
  1242.     DC.B    'Ma_X.',0
  1243.  
  1244. Gadget50Text:
  1245.     DC.B    'Nr Data',0
  1246.  
  1247. Gadget60Text:
  1248.     DC.B    'R',0
  1249.  
  1250. Gadget70Text:
  1251. fname:    DC.B    'Ram:sinedata',0
  1252.  
  1253. Gadget80Text:
  1254.     DC.B    '_About',0
  1255.  
  1256. Gadget90Text:
  1257.     DC.B    '_Quit',0
  1258.  
  1259. Gadget100Text:
  1260.     DC.B    '_Jump Prefs',0
  1261.  
  1262. Gadget110Text:
  1263.     DC.B    'Status:',0
  1264.  
  1265. Gadget120Text:
  1266.     DC.B    'Create Sine',0
  1267.  
  1268. Gadget130Text:
  1269.     DC.B    'A_ppIcon',0
  1270.  
  1271.     CNOP    0,2
  1272.  
  1273. Gadget00Labels:
  1274.     DC.L    Gadget00Lab0
  1275.     DC.L    Gadget00Lab1
  1276.     DC.L    0
  1277.  
  1278. Gadget10Labels:
  1279.     DC.L    Gadget10Lab0
  1280.     DC.L    Gadget10Lab1
  1281.     DC.L    Gadget10Lab2
  1282.     DC.L    0
  1283.  
  1284. Gadget20Labels:
  1285.     DC.L    Gadget20Lab0
  1286.     DC.L    Gadget20Lab1
  1287.     DC.L    0
  1288.  
  1289. Gadget100Labels:
  1290.     DC.L    Gadget100Lab0
  1291.     DC.L    Gadget100Lab1
  1292.     DC.L    0
  1293.  
  1294. Gadget00Lab0:    DC.B    'Cosine',0
  1295. Gadget00Lab1:    DC.B    'Jump',0
  1296.  
  1297.     CNOP    0,2
  1298.  
  1299. Gadget10Lab0:    DC.B    'Byte',0
  1300. Gadget10Lab1:    DC.B    'Word',0
  1301. Gadget10Lab2:    DC.B    'Longword',0
  1302.  
  1303.     CNOP    0,2
  1304.  
  1305. Gadget20Lab0:    DC.B    'Source',0
  1306. Gadget20Lab1:    DC.B    'Data',0
  1307.  
  1308.     CNOP    0,2
  1309.  
  1310. Gadget100Lab0:    DC.B    'Normal',0
  1311. Gadget100Lab1:    DC.B    'Reverse',0
  1312.  
  1313.     CNOP    0,2
  1314.  
  1315. topaz8:
  1316.     DC.L    topazFName8
  1317.     DC.W    8
  1318.     DC.B    $00,$01
  1319.  
  1320. topazFName8:
  1321.     DC.B    'topaz.font',0
  1322.     CNOP    0,2
  1323.  
  1324. GUI_WindowTags:
  1325. GUI_L:
  1326.     DC.L    WA_Left,0
  1327. GUI_T:
  1328.     DC.L    WA_Top,0
  1329. GUI_W:
  1330.     DC.L    WA_Width,0
  1331. GUI_H:
  1332.     DC.L    WA_Height,0
  1333.     DC.L    WA_IDCMP,CYCLEIDCMP!INTEGERIDCMP!IDCMP_GADGETUP!STRINGIDCMP!BUTTONIDCMP!TEXTIDCMP!IDCMP_MENUPICK!IDCMP_CLOSEWINDOW!IDCMP_REFRESHWINDOW
  1334.     DC.L    WA_Flags,WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_SMART_REFRESH!WFLG_ACTIVATE
  1335. GUI_WG:
  1336.     DC.L    WA_Gadgets,0
  1337.     dc.l    WA_NewLookMenus,1
  1338.     DC.L    WA_Title,GUI_WTitle
  1339.     DC.L    WA_Zoom,GUI_Zoom
  1340.     DC.L    WA_AutoAdjust,1
  1341.     DC.L    TAG_DONE
  1342.  
  1343. GUI_WTitle:
  1344.     DC.B    'Cosaque V3.0 The Art/EX4!',0
  1345.     CNOP    0,2
  1346.  
  1347. GUI_Text0:
  1348.     DC.B    1,0
  1349.     DC.B    RP_JAM1
  1350.     DC.B    0
  1351.     DC.W    17,113
  1352.     DC.L    0        ;topaz8
  1353.     DC.L    GUI_IText0
  1354.     DC.L    0
  1355.  
  1356. GUI_IText0:
  1357.     DC.B    'Save',0
  1358.  
  1359.     CNOP    0,2
  1360.  
  1361. GUI_NewMenu0:
  1362.     DC.B    NM_TITLE,0
  1363.     DC.L    GUI_MName0
  1364.     DC.L    0
  1365.     DC.W    0
  1366.     DC.L    0,0
  1367.  
  1368. GUI_NewMenu1:
  1369.     DC.B    NM_ITEM,0
  1370.     DC.L    GUI_MName1
  1371.     DC.L    GUI_MComm1
  1372.     DC.W    0
  1373.     DC.L    0,0
  1374.  
  1375. GUI_NewMenu2:
  1376.     DC.B    NM_ITEM,0
  1377.     DC.L    GUI_MName2
  1378.     DC.L    GUI_MComm2
  1379.     DC.W    0
  1380.     DC.L    0,0
  1381.  
  1382. GUI_NewMenu3:
  1383.     DC.B    NM_ITEM,0
  1384.     DC.L    NM_BARLABEL,0
  1385.     DC.W    0
  1386.     DC.L    0,0
  1387.  
  1388. GUI_NewMenu4:
  1389.     DC.B    NM_ITEM,0
  1390.     DC.L    GUI_MName4
  1391.     DC.L    GUI_MComm4
  1392.     DC.W    0
  1393.     DC.L    0,0
  1394.  
  1395. GUI_NewMenu5:
  1396.     DC.B    NM_ITEM,0
  1397.     DC.L    NM_BARLABEL,0
  1398.     DC.W    0
  1399.     DC.L    0,0
  1400.  
  1401. GUI_NewMenu6:
  1402.     DC.B    NM_ITEM,0
  1403.     DC.L    GUI_MName6
  1404.     DC.L    GUI_MComm6
  1405.     DC.W    0
  1406.     DC.L    0,0
  1407.  
  1408. GUI_NewMenu7:
  1409.     DC.B    NM_TITLE,0
  1410.     DC.L    GUI_MName7
  1411.     DC.L    0
  1412.     DC.W    0
  1413.     DC.L    0,0
  1414.  
  1415. GUI_NewMenu8:
  1416.     DC.B    NM_ITEM,0
  1417.     DC.L    GUI_MName8
  1418.     DC.L    GUI_MComm8
  1419.     DC.W    0
  1420.     DC.L    0,0
  1421.  
  1422. GUI_NewMenu9:
  1423.     DC.B    NM_ITEM,0
  1424.     DC.L    GUI_MName9
  1425.     DC.L    GUI_MComm9
  1426.     DC.W    0
  1427.     DC.L    0,0
  1428.  
  1429. GUI_NewMenu10:
  1430.     DC.B    NM_ITEM,0
  1431.     DC.L    GUI_MName10
  1432.     DC.L    GUI_MComm10
  1433.     DC.W    0
  1434.     DC.L    0,0
  1435.  
  1436. GUI_NewMenu11:
  1437.     DC.B    NM_TITLE,0
  1438.     DC.L    GUI_MName11
  1439.     DC.L    0
  1440.     DC.W    0
  1441.     DC.L    0,0
  1442.  
  1443. GUI_NewMenu12:
  1444.     DC.B    NM_ITEM,0
  1445.     DC.L    GUI_MName12
  1446.     DC.L    GUI_MComm12
  1447.     DC.W    0
  1448.     DC.L    0,0
  1449.  
  1450.     DC.B    NM_END,0
  1451.     DC.L    0,0
  1452.     DC.W    0
  1453.     DC.L    0,0
  1454.  
  1455. GUI_MName0:
  1456.     DC.B    'Project',0
  1457.  
  1458. GUI_MName1:
  1459.     DC.B    'Open...',0
  1460.  
  1461. GUI_MComm1:
  1462.     DC.B    'O',0
  1463.  
  1464. GUI_MName2:
  1465.     DC.B    'Save As...',0
  1466.  
  1467. GUI_MComm2:
  1468.     DC.B    'A',0
  1469.  
  1470. GUI_MName4:
  1471.     DC.B    'About...',0
  1472.  
  1473. GUI_MComm4:
  1474.     DC.B    '?',0
  1475.  
  1476. GUI_MName6:
  1477.     DC.B    'Quit...',0
  1478.  
  1479. GUI_MComm6:
  1480.     DC.B    'Q',0
  1481.  
  1482. GUI_MName7:
  1483.     DC.B    'Edit',0
  1484.  
  1485. GUI_MName8:
  1486.     DC.B    'Reset to Defaults',0
  1487.  
  1488. GUI_MComm8:
  1489.     DC.B    'D',0
  1490.  
  1491. GUI_MName9:
  1492.     DC.B    'Last Saved',0
  1493.  
  1494. GUI_MComm9:
  1495.     DC.B    'L',0
  1496.  
  1497. GUI_MName10:
  1498.     DC.B    'Restore',0
  1499.  
  1500. GUI_MComm10:
  1501.     DC.B    'R',0
  1502.  
  1503. GUI_MName11:
  1504.     DC.B    'Settings',0
  1505.  
  1506. GUI_MName12:
  1507.     DC.B    'Create Icons...',0
  1508.  
  1509. GUI_MComm12:
  1510.     DC.B    'I',0
  1511.  
  1512.     CNOP    0,2
  1513.  
  1514. VersionStr:    dc.b    '$VER: '        ;for 'version' command
  1515. SproName:    dc.b    'Cosaque v3.0',0
  1516. IconName:    dc.b    'Cosaque',0        ;for 'cosaque.info'
  1517.         even
  1518.  
  1519. *******************************************************************************
  1520. * COSAQUE - Sinedata Generation Routines
  1521. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1522. *******************************************************************************
  1523.  
  1524. COS_YES        =    0
  1525. COS_NO        =    1
  1526. UPSIDEDOWN    =    -1
  1527. NORMAL        =    1
  1528. SOURCE        =    0
  1529. DATA        =    1
  1530.  
  1531. _BYTE        =    1
  1532. _WORD        =    2
  1533. _LONG        =    4
  1534.         even
  1535.  
  1536.  
  1537. Do_Sine:    bsr    makeit
  1538.         move.l    RSPtr(pc),a4
  1539.         rts
  1540.  
  1541. *-------------- Open MathFFP Library
  1542. makeit:        move.l    4.w,a6
  1543.         lea    MathFFPName(pc),a1
  1544.         jsr    -408(a6)
  1545.         move.l    d0,_MafBase
  1546.         beq.w    MaffError
  1547.  
  1548. *-------------- Set Sinedata parameters
  1549.  
  1550. SetParams:    move.w    _DataType(pc),d6
  1551.         bset    #5,d6
  1552.  
  1553. *-------------- Allocate Binary sinedata
  1554.  
  1555.         move.l    NrData(pc),d0
  1556.         mulu    SizeType(pc),d0            ;alloc length
  1557.         moveq    #0,d1                ;mem type
  1558.         jsr    _LVOAllocMem(a6)
  1559.         move.l    d0,_MemBase            ;membase ptr
  1560.         beq    Alloc_error
  1561.         
  1562.  
  1563.         tst.w    SineType
  1564.         bne.s    MakeJmpSine
  1565.  
  1566.         bsr    _MakeCosSine            ;make 'COS'
  1567.  
  1568.         bra.s    DoSave
  1569.  
  1570. MakeJmpSine:    bsr    _MakeJmpSine            ;make 'JUMP'
  1571.  
  1572. DoSave:        tst.w    SaveType
  1573.         bne.s    DoSave2
  1574.  
  1575. *-------------- Generate source code...
  1576.  
  1577.         move.l    NrData(pc),d0
  1578.         mulu    #8,d0
  1579.         moveq    #0,d1
  1580.         jsr    _LVOAllocMem(a6)
  1581.         move.l    d0,BufferPt
  1582.         beq    ExitFree
  1583.  
  1584.         bsr    GenerateSrc
  1585.  
  1586. *******************************************************************************
  1587. ;a1        =    Start Addr
  1588. ;d0        =    Buffer Length    (of generated source-code to save)
  1589.  
  1590.         movem.l    d0-d7/a0-a6,-(sp)
  1591.  
  1592.         lea     GUI_Gadgets+7*4(pc),a0
  1593.         move.l    (a0),a0
  1594.         move.l    34(a0),a0
  1595.         move.l    (a0),a0                ;a0.l = filename
  1596.  
  1597.         move.l    BufferPt(pc),a1            ;a1.l = mem to save
  1598.         move.l    NrData(pc),d0
  1599.         mulu    #8,d0                ;d0.l = length
  1600.         move.l    RSPtr(pc),a4
  1601.         bsr    SaveMem2File
  1602.         movem.l    (sp)+,d0-d7/a0-a6
  1603.         
  1604. *******************************************************************************
  1605.  
  1606.         move.l    BufferPt(pc),a1            ;d0
  1607.         move.l    NrData(pc),d0            ;d1
  1608.         mulu    #8,d0                ;d1
  1609.         move.l    4.w,a6
  1610.         jsr    _LVOFreeMem(a6)
  1611.  
  1612.         bra.s    ExitFree
  1613.  
  1614. *-------------- Free Binary Sinedata memory
  1615.  
  1616. DoSave2:    move.l    _MemBase(pc),a0    
  1617.         move.l    NrData(pc),d0
  1618.         mulu    SizeType(pc),d0    
  1619.  
  1620. *******************************************************************************
  1621. ;a0        =    Start Addr
  1622. ;d0        =    Buffer Length    (of Binary to save)
  1623.  
  1624. *-------------- save routine goes here (for Binary data)
  1625.  
  1626.         movem.l    d0-d7/a0-a6,-(sp)
  1627.  
  1628.         lea     GUI_Gadgets+7*4(pc),a0
  1629.         move.l    (a0),a0
  1630.         move.l    34(a0),a0
  1631.         move.l    (a0),a0                ;a0.l = filename
  1632.  
  1633.         move.l    _MemBase(pc),a1
  1634.         move.l    NrData(pc),d0
  1635.         mulu    SizeType(pc),d0    
  1636.         move.l    RSPtr(pc),a4
  1637.         bsr    SaveMem2File
  1638.         
  1639.         movem.l    (sp)+,d0-d7/a0-a6
  1640.  
  1641. *******************************************************************************
  1642.  
  1643. ExitFree    move.l    _MemBase(pc),a1            ;d0
  1644.         move.l    NrData(pc),d0            ;d1
  1645.         mulu    SizeType(pc),d0            ;d1
  1646.         move.l    4.w,a6
  1647.         jsr    _LVOFreeMem(a6)
  1648.  
  1649. *-------------- Close MathFFP Library
  1650. Alloc_error
  1651.         move.l    _MafBase(pc),a1
  1652.         jsr    -414(a6)
  1653. MaffError:    rts
  1654.  
  1655.  
  1656.  
  1657. *******************************************************************************
  1658. * Copy Gadget-data <source> to Record-data <dest>
  1659. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1660. * $Inputs:    a0.l    = string (source)
  1661. *        a2.l    = gadget (dest)
  1662. *******************************************************************************
  1663.  
  1664. CopyGadStr:    move.l    (a0),a0
  1665.         move.l    34(a0),a0
  1666.         move.l    (a0),a0            ;a0=Gadget TextString
  1667.         move.l    a0,a1
  1668.         moveq    #-1,d0
  1669. inclen        addq.l    #1,d0
  1670.         tst.b    (a0)+            ;get string length...
  1671.         bne.s    inclen
  1672.  
  1673. bytecopy    move.b    (a1)+,(a2)+        ;copy byte by byte
  1674.         dbra    d0,bytecopy
  1675.         rts
  1676.  
  1677. *******************************************************************************
  1678. * Copy Record-data <source> TO Gadget-data <dest>
  1679. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  1680. * $Inputs:    a0.l    = gadget (dest)
  1681. *        a2.l    = string (source)
  1682. *******************************************************************************
  1683.  
  1684. CopyStr2Gad:    move.l    (a0),a0
  1685.         move.l    34(a0),a0
  1686.         move.l    (a0),a0            ;a0=Gadget TextString
  1687.         move.l    a2,a1
  1688.  
  1689.         moveq    #-1,d0
  1690. inclen2        addq.l    #1,d0
  1691.         tst.b    (a2)+
  1692.         bne.s    inclen2
  1693.  
  1694. bytecopy2    move.b    (a1)+,(a0)+
  1695.         dbra    d0,bytecopy2
  1696.         rts
  1697.  
  1698. ******************************************************************************
  1699. * Sine Binary -> Source 
  1700. *
  1701.  
  1702. GenerateSrc:    move.l    BufferPt(pc),a0
  1703.         move.l    _MemBase(pc),a1
  1704.         moveq    #0,d0
  1705.         move.l    d0,d1
  1706. gen2:        tst.w    d1
  1707.         bne.s    gen3
  1708.         move.b    #10,(a0)+
  1709.         move.b    #9,(a0)+
  1710.         move.b    #'d',(a0)+
  1711.         move.b    #'c',(a0)+
  1712.         move.b    #'.',(a0)+
  1713.         move.w    _DataType(pc),d7    ;either 'b','w' or 'l'
  1714.         move.b    d7,(a0)+
  1715.         move.b    #9,(a0)+
  1716. gen3:        btst    #7,(a1)
  1717.         beq.s    gen4
  1718.  
  1719.         cmp.w    #"b",_DataType
  1720.         bne.s    CheckW3
  1721.         neg.b    (a1)
  1722.         bra.s    nxt3
  1723.  
  1724. CheckW3:    cmp.w    #"w",_DataType
  1725.         bne.s    IsL3
  1726.         neg.w    (a1)
  1727.         bra.s    nxt3
  1728.  
  1729. IsL3        neg.l    (a1)
  1730. nxt3
  1731.         move.b    #$2D,(a0)+
  1732. gen4        clr.l    d7
  1733.  
  1734.         cmp.w    #"b",_DataType
  1735.         bne.s    CheckW2
  1736.         move.b    (a1)+,d7
  1737.         bra.s    nxt2
  1738.         
  1739. CheckW2:    cmp.w    #"w",_DataType
  1740.         bne.s    IsL2
  1741.         move.w    (a1)+,d7
  1742.         bra.s    nxt2
  1743.         
  1744. IsL2:        move.l    (a1)+,d7
  1745. nxt2
  1746.         clr.w    d6
  1747.         move.l    #$2710,d5
  1748. gen5:        divu    d5,d7
  1749.         tst.w    d7
  1750.         bne.s    gen6
  1751.         tst.w    d6
  1752.         bne.s    gen6
  1753.         swap    d7
  1754.         divu    #10,d5
  1755.         tst.w    d5
  1756.         bne.s    gen5
  1757.         move.b    #$30,(a0)+
  1758.         bra.s    gen7
  1759.  
  1760. gen6:        add.w    #$30,d7
  1761.         move.b    d7,(a0)+
  1762.         clr.w    d7
  1763.         swap    d7
  1764.         moveq    #1,d6
  1765.         divu    #10,d5
  1766.         tst.w    d5
  1767.         bne.s    gen5
  1768. gen7:        addq.l    #1,d0
  1769.         cmp.l    NrData(pc),d0
  1770.         beq.s    gen10
  1771.         cmp.w    #7,d1
  1772.         beq.s    gen8
  1773.         move.b    #$2C,(a0)+
  1774. gen8:        addq.w    #1,d1
  1775.         cmp.w    #8,d1
  1776.         bne.s    gen9
  1777.         clr.w    d1
  1778. gen9:        bra    gen2
  1779.  
  1780. gen10:        move.b    #10,(a0)+
  1781.         move.b    #13,(a0)+
  1782.         clr.b    (a0)
  1783.         sub.l    BufferPt(pc),a0
  1784.         move.l    a0,BufferLen
  1785.         rts
  1786.  
  1787. ******************************************************************************
  1788.  
  1789.  
  1790.  
  1791. CalcSine:    move.l    CosMin(pc),d0
  1792.         jsr    _LVOSPFlt(a5)
  1793.         move.l    d0,CosMin
  1794.         move.l    CosMax(pc),d0
  1795.         jsr    _LVOSPFlt(a5)
  1796.         move.l    d0,CosMax
  1797.         move.l    NrData(pc),d0
  1798.         jsr    _LVOSPFlt(a5)
  1799.         move.l    d0,_NoData
  1800.         move.l    DirType(pc),d0
  1801.         jsr    _LVOSPFlt(a5)
  1802.         move.l    d0,DirType
  1803.         rts
  1804.  
  1805. _MakeCosSine:    move.l    _MafBase(pc),a5
  1806.         bsr.s    CalcSine
  1807.         bsr.s    CalcSine2
  1808.         bra.s    CalcSine3
  1809.  
  1810. CalcSine2:    move.l    CosMin(pc),d0
  1811.         move.l    CosMax(pc),d1
  1812.         jsr    _LVOSPAdd(a5)
  1813.         move.l    #$80000042,d1
  1814.         jsr    _LVOSPDiv(a5)
  1815.         move.l    d0,_FFP1
  1816.         move.l    CosMax(pc),d0
  1817.         move.l    CosMin(pc),d1
  1818.         jsr    _LVOSPSub(a5)
  1819.         move.l    #$80000042,d1
  1820.         jsr    _LVOSPDiv(a5)
  1821.         move.l    d0,_FFP2
  1822.         move.l    #$C90FDA43,d0
  1823.         move.l    _NoData(pc),d1
  1824.         jsr    _LVOSPDiv(a5)
  1825.         move.l    d0,_FFP3
  1826.         rts
  1827.  
  1828. CalcSine3:    move.l    NrData(pc),d7
  1829.         subq.l    #1,d7
  1830.         move.l    #'A',_FFP4
  1831.         move.l    _MemBase(pc),a4
  1832. makeffp1:    bsr.s    MakeFFP
  1833.         move.l    _FFP7(pc),d0
  1834.         move.l    _FFP2(pc),d1
  1835.         jsr    _LVOSPMul(a5)
  1836.         move.l    _FFP1(pc),d1
  1837.         jsr    _LVOSPAdd(a5)
  1838.         move.l    #$80000040,d1
  1839.         jsr    _LVOSPAdd(a5)
  1840.         jsr    _LVOSPFix(a5)
  1841.  
  1842. CheckB        cmp.w    #"b",_DataType
  1843.         bne.s    CheckW
  1844.         move.b    d0,(a4)+
  1845.         bra.s    nxt1
  1846.  
  1847. CheckW        cmp.w    #"w",_DataType
  1848.         bne.s    IsL
  1849.         move.w    d0,(a4)+
  1850.         bra.s    nxt1
  1851.  
  1852. IsL        move.l    d0,(a4)+
  1853. nxt1
  1854.         move.l    _FFP4(pc),d0
  1855.         move.l    _FFP3(pc),d1
  1856.         jsr    _LVOSPAdd(a5)
  1857.         move.l    d0,_FFP4
  1858.         dbra    d7,makeffp1
  1859.         rts
  1860.  
  1861. MakeFFP:    movem.l    d0-d7/a0-a4,-(sp)
  1862.         move.l    #$80000041,d2
  1863.         move.l    d2,_FFP5
  1864.         move.l    d2,_FFP6
  1865.         move.l    #$41,_FFP7
  1866.         moveq    #7,d7
  1867. makeffp3:    move.l    _FFP7(pc),d0
  1868.         move.l    _FFP5(pc),d1
  1869.         jsr    _LVOSPAdd(a5)
  1870.         move.l    d0,_FFP7
  1871.         bsr.s    makeffp4
  1872.         move.l    _FFP7(pc),d0
  1873.         move.l    _FFP5(pc),d1
  1874.         jsr    _LVOSPSub(a5)
  1875.         move.l    d0,_FFP7
  1876.         bsr.s    makeffp4
  1877.         dbra    d7,makeffp3
  1878.         movem.l    (sp)+,d0-d7/a0-a4
  1879.         rts
  1880.  
  1881. makeffp4:    moveq    #1,d2
  1882. makeffp5:    move.l    _FFP4(pc),d0
  1883.         move.l    _FFP6(pc),d1
  1884.         jsr    _LVOSPDiv(a5)
  1885.         move.l    _FFP5(pc),d1
  1886.         jsr    _LVOSPMul(a5)
  1887.         move.l    d0,_FFP5
  1888.         move.l    _FFP6(pc),d0
  1889.         move.l    #$80000041,d1
  1890.         jsr    _LVOSPAdd(a5)
  1891.         move.l    d0,_FFP6
  1892.         dbra    d2,makeffp5
  1893.         rts
  1894.  
  1895. _MakeJmpSine:    move.l    _MafBase(pc),a5
  1896.         bsr.s    CalcJmp1
  1897.         bra.s    CalcJmp2
  1898.  
  1899. CalcJmp1:    clr.l    _FFP8
  1900.         cmp.l    #$FFFFFFFF,DirType
  1901.         bne.s    makeffp8
  1902.         move.l    #$800000C1,_FFP8
  1903. makeffp8:    jsr    CalcSine
  1904.         move.l    #$80000042,d0
  1905.         move.l    _NoData(pc),d1
  1906.         jsr    _LVOSPDiv(a5)
  1907.         move.l    d0,_FFP9
  1908.         rts
  1909.  
  1910. CalcJmp2:    move.l    NrData(pc),d7
  1911.         subq.l    #1,d7
  1912.         move.l    #$800000C1,d6
  1913.         move.l    _MemBase(pc),a4
  1914. makeffp9:    move.l    d6,d0
  1915.         bsr.s    makeffp10
  1916.         move.l    #$80000040,d1
  1917.         jsr    _LVOSPAdd(a5)
  1918.         jsr    _LVOSPFix(a5)
  1919.  
  1920. CheckB4        cmp.w    #"b",_DataType
  1921.         bne.s    CheckW4
  1922.         move.b    d0,(a4)+
  1923.         bra.s    nxt4
  1924.         
  1925. CheckW4        cmp.w    #"w",_DataType
  1926.         bne.s    IsL4
  1927.         move.w    d0,(a4)+
  1928.         bra.s    nxt4
  1929.  
  1930. IsL4        move.l    d0,(a4)+
  1931. nxt4
  1932.         move.l    d6,d0
  1933.         move.l    _FFP9(pc),d1
  1934.         jsr    _LVOSPAdd(a5)
  1935.         move.l    d0,d6
  1936.         dbra    d7,makeffp9
  1937.         rts
  1938.  
  1939. makeffp10:    move.l    d0,d1
  1940.         jsr    _LVOSPMul(a5)
  1941.         move.l    _FFP8(pc),d1
  1942.         jsr    _LVOSPAdd(a5)
  1943.         move.l    d0,d2
  1944.         move.l    CosMax(pc),d0
  1945.         move.l    CosMin(pc),d1
  1946.         jsr    _LVOSPSub(a5)
  1947.         move.l    d2,d1
  1948.         jsr    _LVOSPMul(a5)
  1949.         move.l    DirType(pc),d1
  1950.         jsr    _LVOSPMul(a5)
  1951.         move.l    CosMin(pc),d1
  1952.         jmp    _LVOSPAdd(a5)
  1953.  
  1954.  
  1955. _MemBase:    ds.l    1
  1956. BufferPt:    ds.l    1
  1957. BufferLen:    ds.l    1
  1958. _MafBase:    ds.l    1
  1959. _FFP5:        ds.l    1
  1960. _FFP6:        ds.l    1
  1961. _FFP4:        ds.l    1
  1962. _FFP7:        ds.l    1
  1963. _FFP1:        ds.l    1
  1964. _FFP2:        ds.l    1
  1965. _FFP3:        ds.l    1
  1966. _FFP9:        ds.l    1
  1967. _FFP8:        ds.l    1
  1968. CosMin:        ds.l    1
  1969. CosMax:        ds.l    1
  1970. NrData:        ds.l    1
  1971. _NoData:    ds.l    1
  1972. DirType:    ds.l    1
  1973. _DataType    ds.w    1
  1974. _SaveType    ds.w    1
  1975. SaveType:    ds.w    1
  1976. SizeType:    ds.w    1
  1977. SineType:    ds.w    1
  1978.         even    
  1979. MathFFPName:    dc.b    'mathffp.library',0
  1980.  
  1981.  
  1982.                         ;application icon for wb sleep
  1983.         end
  1984.